package com.blog4j.article.controller;

import cn.dev33.satoken.annotation.SaCheckLogin;
import com.blog4j.article.service.CommentService;
import com.blog4j.article.vo.req.SendCommentReqVo;
import com.blog4j.common.model.Result;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;

/**
 * @author 98k灬
 * @version v1.0.0
 * @Description : 功能描述
 * @Create on : 2024/7/29 12:25
 **/
@RestController
@RequestMapping("/comment")
@RequiredArgsConstructor(onConstructor_ = @Autowired)
public class CommentController {
    private final CommentService commentService;

    /**
     * 给文章评论
     *
     * @param reqVo 评论信息
     * @return 评论成功
     */
    @SaCheckLogin
    @PostMapping("/sendComment")
    public Result sendComment(@RequestBody @Valid SendCommentReqVo reqVo) {
        commentService.sendComment(reqVo);
        return Result.ok();
    }
}
